package edu.bbu.commonproject.backend.server.services.thrift.utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;

/**
 * The thrift socket file object input stream reader.
 */
public class ThriftSocketFileObjectInputStreamReader extends ObjectInputStream
{
	/**
	 * The constructor.
	 * @param in the input stream.
	 * @throws IOException if status is changed then exeption is thrown.
	 */
	public ThriftSocketFileObjectInputStreamReader(InputStream in) throws IOException
	{
		super(in);
	}

	/**
	 * The overrided read class descriptor.
	 */
	protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException
	{
		ObjectStreamClass desc = super.readClassDescriptor();

		if (desc.getName().equals("edu.bbu.commonproject.desktop.client.services.thrift.files.SocketFile") || desc.getName().equals("edu.bbu.license.client.android.communication.services.thrift.files.SocketFile"))
		{
			return ObjectStreamClass.lookup(edu.bbu.commonproject.backend.server.services.thrift.communication.SocketFile.class);
		}

		return desc;
	}

}
